import redis 
import time
redis_cache = redis.Redis(host = "127.0.0.1" , port = 6379 , password = "Redis#Houjiji2019" )
print("begin")
print(redis_cache.dbsize())
begin_pos = 0
while True :
	result = redis_cache.scan(begin_pos , "hack_ip*" , 100000)
	return_pos , datalist = result
	#print(datalist)
	print(time.strftime("%Y-%m-%d %H:%M:%S" , time.localtime(time.time())) , return_pos)
	for key in datalist:
		k = key.decode("utf-8")
		print(redis_cache.type(k).decode("utf-8"))
		redis_cache.delete(k)
		print("delete",k)
 
	if return_pos == 0 :
		break
	begin_pos = return_pos
print("over")
